window.onload=function (){


      var sltCity = document.getElementById('sltCity');
      initCities();

      sltCity.onchange = function (){
            var selectedValue = this.selectedOptions[0].value;

            var selectedCity=    cities.find(function (city){
                  return city.id==selectedValue;
            })

            var sltSchool = document.getElementById('sltSchool');

            sltSchool.innerHTML='';
            for (var i in selectedCity.schools){
                  var opt = '<option value="'+selectedCity.schools[i].id+'">'
                      +selectedCity.schools[i].name+'</option>';

                  sltSchool.innerHTML+=opt;
            }


      }



}

function initCities(){

      var sltCity = document.getElementById('sltCity');
      for(var i in cities){
            // 拼串  1.熟悉html的结构 ；2. 拼写错误
            var opt ='<option value="'+cities[i].id+'">'+cities[i].name+'</option>';
            sltCity.innerHTML+=opt;
      }
}